package com.etone.smartAudit.controller;

import com.etone.smartAudit.error.CustomParameterizedException;
import com.etone.smartAudit.service.QuotaService;
import com.etone.smartAudit.vo.jiutian.CommonVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.rendering.PDFRenderer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import static javax.print.attribute.ResolutionSyntax.DPI;


@RestController
@Api(tags = "稽核能力", value = "AuditController")
@Slf4j
public class AuditController {

    @Autowired
    private QuotaService quotaService;

    @PostMapping("/autoAudit/importQuota")
    @ApiOperation(value = "导入定额库")
    public CommonVO importQuota(@ApiParam(value = "文件") @RequestPart("file") MultipartFile file) {
        return quotaService.importQuota(file);
    }

    @PostMapping("/autoAudit/accountAudit")
    @ApiOperation(value = "结算单审核")
    public CommonVO accountAudit(@ApiParam(value = "文件") @RequestPart("file") MultipartFile file, HttpServletResponse response) {
        return quotaService.accountAudit(file, response);
    }

    @PostMapping("/autoAudit/pdfConvertToImg")
    @ApiOperation(value = "PDF转图片")
    public void pdfConvertToImg(@ApiParam(value = "文件") @RequestPart("file") MultipartFile file, HttpServletResponse response) {
        quotaService.pdfConvertToImg(file,response);
    }

}
